###############################################################################
#
# Copyright (c) 2011 Rainmaker Entertainment
# All Rights Reserved.
#
# This file contains unpublished confidential and proprietary
# information of Rainmaker Entertainment.  The contents of this file
# may not be copied or duplicated, in whole or in part, by any
# means, electronic or hardcopy, without the express prior
# written permission of Rainmaker Entertainment.
#
#    $HeadURL: http://pt/src/trunk/maya/rnkAssetChecks/shader.py $
#    $Revision: 65629 $
#    $Author: wmakari $
#    $Date: 2013-07-04 19:09:30 -0700 (Thu, 04 Jul 2013) $
#
###############################################################################

###############################################################################
## INFOS
###############################################################################

# Common operations for rnkOutsourceChecker


###############################################################################
## MODULES
###############################################################################

import traceback

try :
    import maya.cmds as cmds
    import maya.OpenMaya as OpenMaya
except :
    traceback.print_exc()
    print "Can't load Maya modules."
    
    
import rnkAssetChecks.core as rnkAssetChecksCore
reload(rnkAssetChecksCore)
        


###############################################################################
## FUNCTIONS
###############################################################################  

def checkSidedness(assetRoot):
    """ 
    @brief Check to ensure that all renderable shapes are single sided.
    @return : List
    
    @param assetRoot - String - Asset root node.
    """
    
    result = []
    
    shapesList = rnkAssetChecksCore.listRenderableShapes(assetRoot)
    if not len(shapesList) == 0 :
        result = [x for x in shapesList if cmds.getAttr('%s.doubleSided' % x)]

    return result



def checkOpposite(assetRoot):
    """ 
    @brief Check to ensure that all renderable shapes do not have an opposite orientation. Turn off "opposite" attribute on the shape and invert normals if necessary. Do not rely on "doublesided" attribute.
    @return : List
    
    @param assetRoot - String - Asset root node.
    """
    
    shapes = rnkAssetChecksCore.listRenderableShapes(assetRoot)
    opposite = [x for x in shapes if cmds.getAttr(x + '.opposite')]

    return opposite
